<?php
/**
 * Created by PhpStorm.
 * User: VJLau
 * Date: 2017/11/14
 * Time: 下午3:14
 */

load()->func('tpl');

$operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display';
if ($operation == 'display') {
    $pindex = max(1, intval($_GPC['page']));
    $psize = 20;
    $list = pdo_fetchall("SELECT * FROM " . tablename('bontrip_member')
        . " WHERE uniacid = '{$uniacid}' AND deleted_at is null ORDER BY id DESC LIMIT "
        . ($pindex - 1) * $psize . ',' . $psize);
    $total = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('bontrip_member')
        . " WHERE uniacid = '{$uniacid}' AND deleted_at is null");
    $pager = pagination($total, $pindex, $psize);
} elseif ($operation == 'detail') {
    $id = intval($_GPC['id']);
    $member = pdo_fetch("SELECT * FROM " . tablename('bontrip_member')
        . "WHERE id = {$id} AND deleted_at is null");
    if (empty($member)) {
        message('抱歉，用户不存在或是已经删除！', '', 'error');
    }
    $assessment = unserialize($member['assessment']);
    $assessment['q3'] = explode(',', $assessment['q3']);
} else {
    message('请求方式不存在');
}
include $this->template('member', TEMPLATE_INCLUDEPATH, true);